package com.py.credit.clean.code;

import org.apache.commons.lang3.StringUtils;

/**
 * @Company: WWW.xypy.com.cn
 * @ClassName PermissionCategoryCheck
 * @Description: 许可类别校验
 * @Params: 该校验只允许填写以下校验的值切不为空
 * @Author: YaoS
 * @Create: 2018-12-25 13:48
 **/
public class PermissionCategoryCheck {
    /**
     * 校验规则
     */
    public static final String A = "普通";
    public static final String B = "特许";
    public static final String C = "认可";
    public static final String D = "核准";
    public static final String E = "登记";
    public static final String F = "其他-";
    public static final String G = "其他";

    public boolean run(String data, String extend) {
        if (StringUtils.isEmpty(data.trim())) {
            return false;
        }
        try {
            return checkXklb(data);
        } catch (Exception e) {
            return false;
        }
    }

    private boolean checkXklb(String data) {
        if (data.equals(A) || data.equals(B) || data.equals(C) || data.equals(D)||data.equals(E)||data.equals(G)) {
            return true;
        } else if ( data.length()>3&&data.substring(0,3).equals(F)) {
            return true;
        } else {
            return false;
        }
    }
   
}
